﻿using System;
using Newtonsoft.Json;

namespace Ecobee.Net
{
	/// <summary>
	/// The hold duration type. Valid values: dateTime, nextTransition, indefinite, holdHours.
	/// Hold types ease the calculation of end times for holds. You are always free to provide 
	/// the startDate and startTime for the hold and it will be honored, except where documented. 
	/// The endDate and endTime depend on the hold type chosen. Default is indefinite.
	/// </summary>
	[JsonConverter(typeof(CamelCaseStringEnumConverter))]
	public enum HoldType
	{
		/// <summary>
		/// The value has not been selected or determined.
		/// </summary>
		None,
		/// <summary>
		/// Use the provided startDate, startTime, endDate and endTime for the event. If start 
		/// date/time is not provided, it will be assumed to be right now. End date/time is required.
		/// </summary>
		DateTime,
		/// <summary>
		/// The end date/time will be set to the next climate transition in the program.
		/// </summary>
		NextTransition,
		/// <summary>
		/// The hold will not end and require to be cancelled explicitly.
		/// </summary>
		Indefinite,
		/// <summary>
		/// Use the value in the "holdHours" parameter to set the end date/time for the event.
		/// </summary>
		HoldHours
	}

	/// <summary>
	/// Specifies the details of a hold event used
	/// when calling the SetHold function.
	/// </summary>
	public class Hold : Event
	{
		private HoldType _holdType = HoldType.HoldHours;
		private int _holdHours = 0;

		/// <summary>
		/// The hold duration type. Valid values: dateTime, nextTransition, indefinite, holdHours.
		/// </summary>
		[JsonProperty(PropertyName = "holdType")]
		public HoldType HoldType
		{
			get
			{
				return _holdType;
			}
			set
			{
				_holdType = value;
			}
		}

		/// <summary>
		/// The number of hours to hold for, used and required if holdType = 'holdHours'. 
		/// </summary>
		[JsonProperty(PropertyName = "holdHours")]
		public int HoldHours
		{
			get
			{
				return _holdHours;
			}
			set
			{
				_holdHours = value;
			}
		}
	}
}
